// $Id: logger.cpp 68 2004-11-12 10:44:03Z jonas $
#include "logger.h"
#include <string.h>
#include <stdio.h>
#include <iostream>
using namespace std;

// Inititialize static variables
char Logger::m_prefix[] = {0};

/**
 * Initializes the Logger object by creating the m_prefix used to name output files.
 */
void Logger::setSimulationVars(const char *scenario, unsigned int randSeed)
{
	//strncpy(m_prefix,"simtype.randseed.",128);
	snprintf(m_prefix, 128, "%s.%u.", scenario, randSeed);
}

/**
 * Opens a filestream with a given name, appending the right prefix for the simulation.
 * @param fout A pointer to the fstream object
 * @param suffix The file name suffix
 * @todo Change prefix when the scenario-default is changed.
 */
void Logger::openFile(fstream *fout, const char *suffix)
{
// 	cout << "Fix scenario change-names!!!" << endl;
	char buffer[255];

	strncpy(buffer, m_prefix, 255);

	strncat(buffer, suffix, 255);

	fout->open(buffer, ios::out);
}

